import { getSearchInfoApi } from '@/api/index'

export default {
  namespaced: true,
  state: {
    searchInfo: {}
  },
  // 为了简化数据而生
  getters: {
    goodsList (state) {
      return state.searchInfo.goodsList || []
    },
    trademarkList (state) {
      return state.searchInfo.trademarkList || []
    },
    attrsList (state) {
      return state.searchInfo.attrsList || []
    }
  },
  mutations: {
    setSearchInfo (state, searchInfo) {
      state.searchInfo = searchInfo
    }
  },
  actions: {
    async getSearchInfo ({ commit }, payload = {}) {
      const { data } = await getSearchInfoApi(payload)
      // console.log('searchInfo', data)
      commit('setSearchInfo', data)
    }
  }
}